import { api as Request } from '@/utils/api';
/**
 * 获取字典信息
 * @returns 
 */
export const useDictData = () => {

  /**
   * 
   * @param {string} data 请求参数值
   * @param {Proxy} state 要赋值的对象
   * @param {string} attr 对象的属性名称
   * @param {function or undefined} handleCustomOperation 自定义执行函数
   */
  function getDictDataInfo (data, state, attr, handleCustomOperation) {
    Request.getDictDataInfo({ dictKey: data })
      .then((res) => {
        state[attr] = res.result;
        handleCustomOperation && handleCustomOperation(res.result);
      })
      .catch((res) => { console.log(res) });
  }
  return { getDictDataInfo }
}
